package com.lagou.demo.controller;

import com.lagou.edu.mvcframework.annotations.LagouController;
import com.lagou.edu.mvcframework.annotations.LagouRequestMapping;
import com.lagou.edu.mvcframework.annotations.Security;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * zhangsan/lisi :都可以访问
 * wangwu: /security/aaa
 * zhaoliu: /security/bbb
 */
@LagouController
@LagouRequestMapping("/security")
@Security({"zhangsan", "lisi"})
public class SecurityController {


    @LagouRequestMapping("/aaa")
    @Security("wangwu")
    public void test1(HttpServletRequest request, HttpServletResponse response, String username) throws IOException {
        response.getWriter().write(username + " has permission of  url - '/security/aaa' ");
    }

    @LagouRequestMapping("/bbb")
    @Security("zhaoliu")
    public void test2(HttpServletRequest request, HttpServletResponse response, String username) throws IOException {
        response.getWriter().write(username + " has permission of url - ' /security/bbb'");
    }

}
